/*	=======================================================================	*/
/// <remarks>
/// Version:
///		- number:	0.0.7
///		- build:	20040609
///		- status:	beta
/// </remarks>
/*	=======================================================================	*/
/// <remarks>
/// Global Variables
/// </remarks>
	var x_grp = new ClassX_Group(x_debug);
/*	=======================================================================	*/
/// <remarks>
/// Class: ClassX_Group
/// The ClassX_Group object class has the following purpose/function:
///	- supplies client-side properties and methods for 'grpform' objects
/// </remarks>
/*	-----------------------------------------------------------------------	*/
/// <summary>
/// The ClassX_Group object class is constructed as follows:
///		var thisobj = new ClassX_Group(dbg);
/// - where:
///		- dbg:	debugging switch
/// </summary>
function ClassX_Group(dbg) {
	/*	-------------------------------------------	*/
	/// <remarks>Properties: Public</remarks>
	/*	-------------------------------------------	*/
	this.parameter = "";
	/*	-------------------------------------------	*/
	/// <remarks>Properties: Private</remarks>
	/*	-------------------------------------------	*/
	var _self = this;	// self allows for a method/property to be called internally
	var _debug = (dbg)? dbg : false;
	var _id = "";
	/*	-------------------------------------------	*/
	/// <remarks>Region: Accessor methods</remarks>
	/*	-------------------------------------------	*/
	this.GetID = function() { return(_id); }
	/*	-------------------------------------------	*/
	/// <remarks>Region: Public methods</remarks>
	/*	-------------------------------------------	*/
	this.Template = _Template;
	this.Url = _Url;
	this.Go = _Go;
	this.Goto = _Goto;
	this.Change = _Change;
	this.Sort = _Sort;
	this.Order = _Order;
	this.Filter = _Filter;
	this.Form = _Form;
	this.Submit = _Submit;
	/// <summary>Method:_Template</summary>
	function _Template(thisvar) {
		_Debug("_Template:", "thisvar", thisvar);
	}
	/// <summary>Method:_Url</summary>
	function _Url(val) {
		_Debug("_Url:", "val", val);
		document.location.href = val;
	}
	/// <summary>Method:_Go</summary>
	function _Go(sel) {
		_Debug("_Go:", "sel", sel.value);
		document.location.href = sel.value;
	}
	/// <summary>Method:_Goto</summary>
	function _Goto(it, fm) {
		_Debug("_Goto:", "it", it);
		var act = fm.action;
		if (act.substr(0, 7) == "x_data") {
			act = "x_portal" + act.substr(7);
			if (act.substr(act.length - 12) == "&device=data") 
				act = act.substr(0, act.length - 12);
			fm.action = act;
		}
		switch (it) {
			case "first":	fm.action.value = "FIRST";	break;
			case "last":	fm.action.value = "LAST";		break;
			case "next":	fm.action.value = "NEXT";		break;
			case "prev":	fm.action.value = "PREV";		break;
			case "filter":	fm.action.value = "FIRST";
			case "rowsperpage":	break;
			default:		fm.Page_No.value = it;		break;
		}
		fm.submit();
	}
	/// <summary>Method:_Change</summary>
	function _Change(fd, vl) { 
		_Debug("_Change:", "vl", vl);
		fd.value = vl; 
	}
	/// <summary>Method:_Sort</summary>
	function _Sort(st, fm) {
		_Debug("_Sort:", "st", st);
		fm.Sort_Col.value = st;
		fm.Page_No.value = "1";
		fm.submit();
	}
	/// <summary>Method:_Order</summary>
	function _Order(st, fm, url) {
		_Debug("_Order:", "st", st, "url", url);
		fm.SortOrder.value = st;
		fm.action = (url)? url : document.location.href;
		fm.submit();
	}
	/// <summary>Method:_Filter</summary>
	function _Filter(fm, url) {
		_Debug("_Filter:", "url", url);
		fm.action = (url)? url : document.location.href;
		fm.submit();
	}
	/// <summary>Method:_Form</summary>
	// NB: Needs some checking + testing
	function _Form(frm, typ, lnk, id, nme, prc, url, param) {
		thisurl = (url)? url : "nm_portal.asp";
		thisurl += "?link=";
		if (typ == "link") 
			thisurl += lnk;
		else if (typ == "form") {
			thisurl += lnk;
			thisurl += "&form=" + nme;
			}
		else if (typ == "serv") {
			thisurl += lnk;
			thisurl += "&service=" + nme;
			thisurl += "&process=" + prc;
			}
		else
			return;
		// link, form or service...
		if (id!='')
			thisurl += "&id=" + id;
		if (param) {
			thisurl += "&" + param;
		}
		frm.action = thisurl;
		frm.submit();
	}
	/// <summary>Method:_Submit</summary>
	// NB: Needs some checking + testing
	function _Submit(frm, chk, pmt) {
		var ok = (chk)? checkForm(frm, pmt) : true;
		if (ok)
			frm.submit();
	}
	/*	-------------------------------------------	*/
	/// <remarks>Region: Private methods</remarks>
	/*	-------------------------------------------	*/
	/// <summary>Method:_RaiseError</summary>
	function _RaiseError(thiserr) {
		_Debug("RaiseError:", "thiserr", thiserr);
		throw (thiserr);
	}
	/// <summary>Method:_Debug - write debugging message. First param is the method label, followed by name, value pairs</summary>
	function _Debug(arg) {
		if (_debug) {
			s = "<!-- ClassX_Group::"
			s = s.concat(arguments[0], ":");
			var argn = arguments.length;
			for(var i=1; i<argn; i=i+2)
				s = s.concat(arguments[i], ":", arguments[i+1], " ");
			alert(s.concat("-->\n"));
		}
	}
	/// <summary>Method:checkForm</summary>
	function checkForm(fm, pt) {
		var el, nm, ch, sl;
		for (var i=0; i<fm.elements.length; i++) {
	    	el = fm.elements[i];
			nm = el.name
			ch = nm.substr(0, 7);
	    	if (ch == 'select_') {
				if (el.value > 0) {
					sl = document.getElementsByName('editcheck_' + nm.substr(7));
					if (sl[0].value == "") {
						alert(pt);
						return(false);
					}
				}
			}
		}
		return(true);
	}
}





